

import 'package:flower/pages/guide_page.dart';
import 'package:flower/pages/index_page.dart';
import 'package:flower/pages/register_page.dart';
import 'package:flower/pages/tabs/detail/flower_detail.dart';
import 'package:flower/pages/tabs/shoppingcart/cart_page.dart';
import 'package:flower/pages/tabs/shoppingcart/children/order_submit.dart';

import 'package:flower/pages/tabs/user/children/address.dart';
import 'package:flower/pages/tabs/user/children/collection.dart';
import 'package:flower/pages/tabs/user/children/comment.dart';
import 'package:flower/pages/tabs/user/children/coupon.dart';
import 'package:flower/pages/tabs/user/children/personal.dart';
import 'package:flower/pages/tabs/user/children/point.dart';
import 'package:flower/pages/tabs/user/children/setting.dart';

import 'package:flutter/material.dart';

import '../pages/login_page.dart';

final Map<String,Function> routes={
  '/':(context)=> GuidePage(),
  '/login':(context)=>const LoginPage(),
  '/register':(context)=>const RegisterPage(),
  '/index':(context)=>const IndexPage(),
  '/cart':(context)=>const Cart(),
  '/collection':(context)=>const Collection(),
  '/setting':(context)=>const Settings(),
  '/comment':(context)=>const Comment(),
  '/address':(context)=>const Address(),
  '/personal':(context)=>const Personal(),
  '/detail':(context)=>const FlowerDetailPage(flowerId: 1,),
  '/submit':(context)=>const OrderSubmit(),
  '/coupon':(context)=>const CouponList(),
  '/point':(context)=>const Point(),
};

Route routeGenerator(RouteSettings settings) {
  final String? name = settings.name;
  final Function? pageBuilder = routes[name];
  if (pageBuilder != null) {
    if (settings.arguments != null) {
      return MaterialPageRoute(builder: (context) => pageBuilder(context, arguments: settings.arguments));
    } else {
      return MaterialPageRoute(builder: (context) => pageBuilder(context));
    }
  }
  return MaterialPageRoute(builder: (context) =>  const LoginPage());
}


